import request from '@/utils/request'
import { imageServUrl } from '@/utils/constants'

export function getImageList(params) {
  return request({
    url: imageServUrl + '/images/',
    method: 'get',
    params
  })
}

export function getImageListByKeywordsApi(params) {
  return request({
    url: imageServUrl + '/images_keyword',
    method: 'get',
    params
  })
}

export function uploadImage(params) {
  return request({
    url: imageServUrl + '/file/image',
    method: 'post',
    params
  })
}

export function insertImage(data) {
  return request({
    url: imageServUrl + '/image',
    method: 'post',
    data
  })
}
export function getImageById(id) {
  return request({
    url: imageServUrl + '/image/' + id,
    method: 'get'
  })
}
export function updateImageById(data) {
  return request({
    url: imageServUrl + '/image/' + data.id,
    method: 'put',
    data
  })
}

export function delImageById(imageId) {
  return request({
    url: imageServUrl + '/image/' + imageId,
    method: 'delete'
  })
}


export function getTipsKeywordsFromPrefixApi(keywords) {
  return request({
    url: imageServUrl + '/keywords/' + keywords,
    method: 'get'
  })
}

export function fetchOssTokenApi () {
  return request({
    url: imageServUrl + "/file/token",
    method: 'get'
  })
}